services:
  agent:
    command: sh -c 'bin/wait && python -m deeppavlov_agent.run agent.pipeline_config=assistant_dists/dream_ranking_and_sf_based_dm/pipeline_conf.json'
    environment:
      WAIT_HOSTS: "sentseg:8011, ranking-and-sf-based-response-selector:8082,
          speech-function-predictor:8107, speech-function-classifier:8108,
          dff-intent-responder-skill:8012, intent-catcher:8014, ner:8021,
          factoid-qa:8071, kbqa:8072, entity-linking:8075, wiki-parser:8077, text-qa:8078,
          combined-classification:8087, fact-retrieval:8100, entity-detection:8103,
          sentence-ranker:8128, property-extraction:8136, prompt-selector:8135, openai-api-chatgpt:8145,
          dff-dream-persona-chatgpt-prompted-skill:8137, dff-dream-faq-prompted-skill:8170,
          openai-api-chatgpt-16k:8167, summarization-annotator:8058, dialog-summarizer:8059"
      WAIT_HOSTS_TIMEOUT: ${WAIT_TIMEOUT:-1000}
      HIGH_PRIORITY_INTENTS: 1
      RESTRICTION_FOR_SENSITIVE_CASE: 1
      ALWAYS_TURN_ON_ALL_SKILLS: 0
      LANGUAGE: EN
      FALLBACK_FILE: fallbacks_dream_en.json

  ranking-and-sf-based-response-selector:
    env_file: [ .env ]
    build:
      args:
        SERVICE_PORT: 8082
        SERVICE_NAME: response_selector
        LANGUAGE: EN
        SENTENCE_RANKER_ANNOTATION_NAME: sentence_ranker
        SENTENCE_RANKER_SERVICE_URL: http://sentence-ranker:8128/respond
        SENTENCE_RANKER_TIMEOUT: 3
        N_UTTERANCES_CONTEXT: 5
        FILTER_TOXIC_OR_BADLISTED: 1
        FALLBACK_FILE: fallbacks_dream_en.json
      context: .
      dockerfile: ./response_selectors/ranking_and_sf_based_response_selector/Dockerfile
    command: flask run -h 0.0.0.0 -p 8082
    environment:
      - FLASK_APP=server
    deploy:
      resources:
        limits:
          memory: 100M
        reservations:
          memory: 100M

  sentseg:
    env_file: [ .env ]
    build:
      context: ./annotators/SentSeg/
    command: flask run -h 0.0.0.0 -p 8011
    environment:
      - FLASK_APP=server
    deploy:
      resources:
        limits:
          memory: 1.5G
        reservations:
          memory: 1.5G

  dff-intent-responder-skill:
    env_file: [ .env ]
    build:
      args:
        SERVICE_PORT: 8012
        SERVICE_NAME: dff_intent_responder_skill
        INTENT_RESPONSE_PHRASES_FNAME: intent_response_phrases.json
      context: .
      dockerfile: ./skills/dff_intent_responder_skill/Dockerfile
    command: gunicorn --workers=1 server:app -b 0.0.0.0:8012 --reload
    deploy:
      resources:
        limits:
          memory: 128M
        reservations:
          memory: 128M

  intent-catcher:
    env_file: [ .env ]
    build:
      context: .
      dockerfile: ./annotators/IntentCatcherTransformers/Dockerfile
      args:
        SERVICE_PORT: 8014
        CONFIG_NAME: intents_model_dp_config.json
        INTENT_PHRASES_PATH: intent_phrases.json
    command: python -m flask run -h 0.0.0.0 -p 8014
    environment:
      - FLASK_APP=server
      - CUDA_VISIBLE_DEVICES=0
    deploy:
      resources:
        limits:
          memory: 3.5G
        reservations:
          memory: 3.5G

  ner:
    env_file: [ .env ]
    build:
      args:
        CONFIG: ner_case_agnostic_multilingual_bert_base_extended.json
        SERVICE_PORT: 8021
        SRC_DIR: annotators/NER_deeppavlov
        COMMIT: f5117cd9ad1e64f6c2d970ecaa42fc09ccb23144
      context: ./
      dockerfile: annotators/NER_deeppavlov/Dockerfile
    command: flask run -h 0.0.0.0 -p 8021
    environment:
      - FLASK_APP=server
      - CUDA_VISIBLE_DEVICES=0
    tty: true
    deploy:
      resources:
        limits:
          memory: 2G
        reservations:
          memory: 2G

  factoid-qa:
    env_file: [ .env ]
    build:
      args:
        SERVICE_PORT: 8071
        SERVICE_NAME: factoid_qa
      context: .
      dockerfile: ./skills/factoid_qa/Dockerfile
    command: flask run -h 0.0.0.0 -p 8071
    environment:
      - FLASK_APP=server
    deploy:
      resources:
        limits:
          memory: 256M
        reservations:
          memory: 256M

  entity-linking:
    env_file: [ .env ]
    build:
      args:
        SERVICE_PORT: 8075
        SERVICE_NAME: entity_linking
        CONFIG: entity_linking_eng.json
        SRC_DIR: annotators/entity_linking
      context: ./
      dockerfile: annotators/entity_linking/Dockerfile
    environment:
      - CUDA_VISIBLE_DEVICES=0
    deploy:
      resources:
        limits:
          memory: 2.5G
        reservations:
          memory: 2.5G

  wiki-parser:
    env_file: [ .env ]
    build:
      args:
        SERVICE_PORT: 8077
        SERVICE_NAME: wiki_parser
        WIKI_LITE_DB: http://files.deeppavlov.ai/kbqa/wikidata/wikidata2022.hdt
        WIKI_LITE_INDEX_DB: http://files.deeppavlov.ai/kbqa/wikidata/wikidata2022.hdt.index.v1-1
        WIKI_CACHE_DB: http://files.deeppavlov.ai/kbqa/wikidata/wikidata_cache.json
        CONFIG: wiki_parser.json
        SRC_DIR: annotators/wiki_parser
        COMMIT: ff5b156d16a949c3ec99da7fb60ae907dec37a41
        FAST: 1
      context: ./
      dockerfile: annotators/wiki_parser/Dockerfile
    command: flask run -h 0.0.0.0 -p 8077
    environment:
      - CUDA_VISIBLE_DEVICES=''
      - FLASK_APP=server
    deploy:
      resources:
        limits:
          memory: 256M
        reservations:
          memory: 256M

  text-qa:
    env_file: [ .env ]
    build:
      args:
        SERVICE_PORT: 8078
        SERVICE_NAME: text_qa
        CONFIG: qa_eng.json
      context: services/text_qa
      dockerfile: Dockerfile
    command: flask run -h 0.0.0.0 -p 8078
    environment:
      - CUDA_VISIBLE_DEVICES=0
      - FLASK_APP=server
      - LANGUAGE=EN
    deploy:
      resources:
        limits:
          memory: 3G
        reservations:
          memory: 3G

  kbqa:
    env_file: [ .env ]
    build:
      args:
        SERVICE_PORT: 8072
        SERVICE_NAME: kbqa
        CONFIG: kbqa_cq_mt_bert_lite.json
        SRC_DIR: annotators/kbqa/
        COMMIT: 283a25e322e8fedc6ff0c159e4ec76bb165ae405
      context: ./
      dockerfile: annotators/kbqa/Dockerfile
    command: flask run -h 0.0.0.0 -p 8072
    environment:
      - CUDA_VISIBLE_DEVICES=0
      - FLASK_APP=server
    deploy:
      resources:
        limits:
          memory: 5G
        reservations:
          memory: 5G

  combined-classification:
    env_file: [ .env ]
    build:
      args:
        SERVICE_PORT: 8087
        SERVICE_NAME: combined_classification
        CONFIG: combined_classifier.json
      context: .
      dockerfile: ./annotators/combined_classification/Dockerfile
    command: gunicorn --workers=1 server:app -b 0.0.0.0:8087 --timeout 600
    environment:
      - CUDA_VISIBLE_DEVICES=0
    deploy:
      resources:
        limits:
          memory: 2G
        reservations:
          memory: 2G

  fact-retrieval:
    env_file: [ .env ]
    build:
      args:
        SERVICE_PORT: 8100
        SERVICE_NAME: fact_retrieval
        CONFIG: configs/fact_retrieval_page.json
        CONFIG_WIKI: configs/page_extractor.json
        CONFIG_WHOW: configs/whow_page_extractor.json
        SRC_DIR: annotators/fact_retrieval/
        COMMIT: 4b3e60c407644b750c9dc292ac6bf206081fb9d0
        N_FACTS: 3
      context: ./
      dockerfile: annotators/fact_retrieval/Dockerfile
    command: flask run -h 0.0.0.0 -p 8100
    environment:
      - CUDA_VISIBLE_DEVICES=0
      - FLASK_APP=server
    deploy:
      resources:
        limits:
          memory: 4G
        reservations:
          memory: 4G

  entity-detection:
    env_file: [ .env ]
    build:
      args:
        SERVICE_NAME: entity_detection
        SEQ_TAG_CONFIG: wikipedia_entity_detection_distilbert.json
        CONFIG: entity_detection_eng.json
        LOWERCASE: 1
        SERVICE_PORT: 8103
        SRC_DIR: annotators/entity_detection/
        FINEGRAINED: 0
      context: ./
      dockerfile: annotators/entity_detection/Dockerfile
    command: flask run -h 0.0.0.0 -p 8103
    environment:
      - FLASK_APP=server
      - CUDA_VISIBLE_DEVICES=0
    deploy:
      resources:
        limits:
          memory: 2.5G
        reservations:
          memory: 2.5G

  prompt-selector:
    env_file: [ .env ]
    build:
      args:
        SERVICE_PORT: 8135
        SERVICE_NAME: prompt_selector
        SENTENCE_RANKER_SERVICE_URL: http://sentence-ranker:8128/respond
        N_SENTENCES_TO_RETURN: 3
        PROMPTS_TO_CONSIDER: dream_persona,dream_faq
      context: .
      dockerfile: ./annotators/prompt_selector/Dockerfile
    command: flask run -h 0.0.0.0 -p 8135
    environment:
      - FLASK_APP=server
    deploy:
      resources:
        limits:
          memory: 100M
        reservations:
          memory: 100M

  sentence-ranker:
    env_file: [ .env ]
    build:
      args:
        SERVICE_PORT: 8128
        SERVICE_NAME: sentence_ranker
        PRETRAINED_MODEL_NAME_OR_PATH: sentence-transformers/all-MiniLM-L6-v2
      context: ./services/sentence_ranker/
    command: flask run -h 0.0.0.0 -p 8128
    environment:
      - CUDA_VISIBLE_DEVICES=0
      - FLASK_APP=server
    deploy:
      resources:
        limits:
          memory: 3G
        reservations:
          memory: 3G

  openai-api-chatgpt:
    env_file: [ .env ]
    build:
      args:
        SERVICE_PORT: 8145
        SERVICE_NAME: openai_api_chatgpt
        PRETRAINED_MODEL_NAME_OR_PATH: gpt-3.5-turbo
      context: .
      dockerfile: ./services/openai_api_lm/Dockerfile
    command: flask run -h 0.0.0.0 -p 8145
    environment:
      - CUDA_VISIBLE_DEVICES=0
      - FLASK_APP=server
    deploy:
      resources:
        limits:
          memory: 500M
        reservations:
          memory: 100M

  dff-dream-persona-chatgpt-prompted-skill:
    env_file: [ .env,.env_secret ]
    build:
      args:
        SERVICE_PORT: 8137
        SERVICE_NAME: dff_dream_persona_prompted_skill
        PROMPT_FILE: common/prompts/dream_persona.json
        GENERATIVE_SERVICE_URL: http://openai-api-chatgpt:8145/respond
        GENERATIVE_SERVICE_CONFIG: openai-chatgpt.json
        GENERATIVE_TIMEOUT: 120
        N_UTTERANCES_CONTEXT: 7
        ENVVARS_TO_SEND: OPENAI_API_KEY,OPENAI_ORGANIZATION
      context: .
      dockerfile: ./skills/dff_template_prompted_skill/Dockerfile
    deploy:
      resources:
        limits:
          memory: 128M
        reservations:
          memory: 128M

  dff-google-api-skill:
    env_file: [ .env,.env_secret ]
    build:
      args:
        SERVICE_PORT: 8162
        SERVICE_NAME: dff_google_api_skill
        ENVVARS_TO_SEND: OPENAI_API_KEY,GOOGLE_CSE_ID,GOOGLE_API_KEY
      context: .
      dockerfile: ./skills/dff_google_api_skill/Dockerfile
    deploy:
      resources:
        limits:
          memory: 128M
        reservations:
          memory: 128M

  property-extraction:
    env_file: [.env]
    build:
      args:
        CONFIG: t5_generative_ie_lite_infer.json
        SERVICE_PORT: 8136
        SRC_DIR: annotators/property_extraction/
        SERVICE_NAME: property_extraction
      context: ./
      dockerfile: annotators/property_extraction/Dockerfile
    command: flask run -h 0.0.0.0 -p 8136
    environment:
      - FLASK_APP=server
    deploy:
      resources:
        limits:
          memory: 7G
        reservations:
          memory: 7G

  dff-dream-faq-prompted-skill:
    env_file: [ .env,.env_secret ]
    build:
      args:
        SERVICE_PORT: 8170
        SERVICE_NAME: dff_dream_faq_prompted_skill
        PROMPT_FILE: common/prompts/dream_faq.json
        GENERATIVE_SERVICE_URL: http://openai-api-chatgpt-16k:8167/respond
        GENERATIVE_SERVICE_CONFIG: openai-chatgpt.json
        GENERATIVE_TIMEOUT: 120
        N_UTTERANCES_CONTEXT: 7
        ENVVARS_TO_SEND: OPENAI_API_KEY,OPENAI_ORGANIZATION
      context: .
      dockerfile: ./skills/dff_template_prompted_skill/Dockerfile
    deploy:
      resources:
        limits:
          memory: 128M
        reservations:
          memory: 128M

  openai-api-chatgpt-16k:
    env_file: [ .env ]
    build:
      args:
        SERVICE_PORT: 8167
        SERVICE_NAME: openai_api_chatgpt_16k
        PRETRAINED_MODEL_NAME_OR_PATH: gpt-3.5-turbo-16k
      context: .
      dockerfile: ./services/openai_api_lm/Dockerfile
    command: flask run -h 0.0.0.0 -p 8167
    environment:
      - FLASK_APP=server
    deploy:
      resources:
        limits:
          memory: 500M
        reservations:
          memory: 100M

  summarization-annotator:
    env_file: [ .env ]
    build:
      args:
        SERVICE_PORT: 8058
        SERVICE_NAME: summarization_annotator
        SUMMARIZATION_REQUEST_TIMEOUT: 10
      context: ./annotators/summarization_annotator/
    command: flask run -h 0.0.0.0 -p 8058
    environment:
      - FLASK_APP=server
    deploy:
      resources:
        limits:
          memory: 256M
        reservations:
          memory: 256M

  dialog-summarizer:
    env_file: [ .env ]
    build:
      args:
        SERVICE_PORT: 8059
        SERVICE_NAME: dialog_summarizer
        PRETRAINED_MODEL_NAME: "knkarthick/MEETING_SUMMARY"
      context: ./services/dialog_summarizer/
    command: flask run -h 0.0.0.0 -p 8059
    environment:
      - CUDA_VISIBLE_DEVICES=0
      - FLASK_APP=server
    deploy:
      resources:
        limits:
          memory: 4G
        reservations:
          memory: 4G

  speech-function-classifier:
    env_file: [ .env ]
    build:
      args:
        SERVICE_PORT: 8108
        SERVICE_NAME: speech_function_classifier
      context: ./annotators/speech_function_classifier/
    command: gunicorn --workers=1 server:app -b 0.0.0.0:8108
    environment:
      - CUDA_VISIBLE_DEVICES=0
    deploy:
      resources:
        limits:
          memory: 1G
        reservations:
          memory: 1G

  speech-function-predictor:
    env_file: [ .env ]
    build:
      args:
        SERVICE_PORT: 8107
        SERVICE_NAME: speech_function_predictor
      context: ./annotators/speech_function_predictor
    command: gunicorn --workers=1 server:app -b 0.0.0.0:8107
    environment:
      - CUDA_VISIBLE_DEVICES=0
    deploy:
      resources:
        limits:
          memory: 1G
        reservations:
          memory: 1G

version: '3.7'
